BoxPlot Company Analysis
import matplotlib.pyplot as plt
import numpy as np
# Sample data
data = [15, 20, 25, 30, 35, 40, 100] # 100 is an outlier
plt.boxplot(data,notch=True,patch_artist=True)
plt.title("Basic Box Plot")
plt.ylabel("Values")
plt.show()
if __name__ == "__main__":
import pandas as pd
data = {
'Company': ['A', 'B'],
'Revenue': [100000, 120000],
'Profit': [20000, 25000],
'Assets': [150000, 180000],
'Equity': [80000, 90000]
}
df = pd.DataFrame(data)
df['Profit Margin'] = df['Profit'] / df['Revenue']
df['ROA'] = df['Profit'] / df['Assets']
df['ROE'] = df['Profit'] / df['Equity']
print(df)
import pandas as pd
import matplotlib.pyplot as plt
if __name__== "__main__":
#Trend Analysis (Revenue Growth)
data = {
'Year': [2020, 2021, 2022, 2023],
'Revenue': [80000, 90000, 120000, 150000]
}
df = pd.DataFrame(data)
# Calculate growth rate
df['Growth Rate'] = df['Revenue'].pct_change()
print(df)
#Expense Analysis (Cost Control)
data = {
'Revenue': [100000, 120000, 140000],
'Expenses': [70000, 90000, 110000]
}
df = pd.DataFrame(data)
df['Expense Ratio'] = df['Expenses'] / df['Revenue']
print(df)
#Profit Trend Visualization
years = [2020, 2021, 2022, 2023]
profit = [10000, 15000, 20000, 18000]
plt.plot(years, profit, marker='o')
plt.title("Profit Trend")
plt.xlabel("Year")
plt.ylabel("Profit")
plt.show()
#Break-even Analysis
fixed_cost = 50000
price_per_unit = 20
variable_cost_per_unit = 10
break_even_units = fixed_cost / (price_per_unit - variable_cost_per_unit)
print("Break-even units:", break_even_units)
#Moving Average (Stock Analysis)
#Smooth out stock price fluctuations
prices = [100, 105, 102, 110, 115]
df = pd.DataFrame({'Price': prices})
df['Moving Average'] = df['Price'].rolling(window=3).mean()
print(df)
#Correlation Analysis
data = {
'Revenue': [100, 120, 140, 160],
'Profit': [20, 25, 30, 35]
}
df = pd.DataFrame(data)
correlation = df['Revenue'].corr(df['Profit'])
print("Correlation:", correlation)
#Cash Flow Analysis
cash_in = [50000, 60000, 55000]
cash_out = [40000, 45000, 50000]
net_cash_flow = [i - o for i, o in zip(cash_in, cash_out)]
print("Net Cash Flow:", net_cash_flow)